import request from '@/utils/request'

export function login(username, password) {
  return request({
    url: '/admin/login',
    method: 'post',
    data: {
      username,
      password
    }
  })
}

export function getInfo() {
  return request({
    url: '/admin/info',
    method: 'get',
  })
}

export function logout() {
  return request({
    url: '/admin/logout',
    method: 'post'
  })
}

export function fetchList(params) {
  return request({
    url: '/admin/list',
    method: 'get',
    params: params
  })
}

// 定义方法
export function sitQuietlClockList(params) {
  return request({
    url: '/sit-quietly-clock/list',
    method: 'get',
    params: params
  })
}

// 昨天未打卡列表
export function preClockList(params) {
  return request({
    url: '/sit-quietly-clock/pre-clock-list',
    method: 'get',
    params: params
  })
}

export function statClockData(params) {
  return request({
    url: '/sit-quietly-clock/pre-clock-data',
    method: 'get',
    params: params
  })
}

/**
 * 增加
 */
export function addClock(data) {
  return request({
    url: '/sit-quietly-clock/clock',
    method: 'post',
    data: data
  })
}

  // 删除
  export function deleteClock(id) {
    return request({
      url: '/sit-quietly-clock/clock/'+ id,
      method: 'delete',
    })
  }

/**
 * 修改
 */
export function updateClock(data) {
  return request({
    url: '/sit-quietly-clock/clock',
    method: 'put',
    data: data
  })
}

export function listUsername(type) {
  return request({
    url: '/sit-quietly-clock/username/'+ type,
    method: 'get',
  })

}
/**
 * 获取旷卡用户名称
 * @param {*} type 
 * @returns 
 */
export function listUnClock(type) {
  return request({
    url: '/sit-quietly-clock/listUnClock/'+ type,
    method: 'get',
  })

}

 



///////////////////////////////////////////////////////////////////////////

export function createAdmin(data) {
  return request({
    url: '/admin/register',
    method: 'post',
    data: data
  })
}

export function updateAdmin(id, data) {
  return request({
    url: '/admin/update/' + id,
    method: 'post',
    data: data
  })
}

export function updateStatus(id, params) {
  return request({
    url: '/admin/updateStatus/' + id,
    method: 'post',
    params: params
  })
}

export function deleteAdmin(id) {
  return request({
    url: '/admin/delete/' + id,
    method: 'post'
  })
}

export function getRoleByAdmin(id) {
  return request({
    url: '/admin/role/' + id,
    method: 'get'
  })
}

export function allocRole(data) {
  return request({
    url: '/admin/role/update',
    method: 'post',
    data: data
  })
}
